package com.neulogistics.core.customercenter.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 客户表
 * @TableName tb_customer
 */
@TableName(value ="tb_customer", autoResultMap = true)
@Data
public class CustomerPO implements Serializable {
    /**
     * 客户id
     */
    @TableId(value = "customer_id", type = IdType.AUTO)
    private Integer customerId;

    /**
     * 客户名
     */
    @TableField(value = "customer_name", condition = SqlCondition.LIKE)
    private String customerName;

    /**
     * 单位名
     */
    @TableField(value = "flats_name", condition = SqlCondition.LIKE)
    private String flatsName;

    /**
     * 身份证号
     */
    @TableField(value = "customer_identity", condition = SqlCondition.LIKE)
    private String customerIdentity;

    /**
     * 客户电话
     */
    @TableField(value = "customer_phone", condition = SqlCondition.LIKE)
    private String customerPhone;

    /**
     * 收货地址
     */
    @TableField(value="receiver_address",typeHandler = JacksonTypeHandler.class)
    private JSONObject receiverAddress;

    /**
     * 邮件地址
     */
    @TableField(value = "customer_email")
    private String customerEmail;

    /**
     * 座机号
     */
    @TableField(value = "customer_landline")
    private String customerLandline;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CustomerPO other = (CustomerPO) that;
        return (this.getCustomerId() == null ? other.getCustomerId() == null : this.getCustomerId().equals(other.getCustomerId()))
            && (this.getCustomerName() == null ? other.getCustomerName() == null : this.getCustomerName().equals(other.getCustomerName()))
            && (this.getFlatsName() == null ? other.getFlatsName() == null : this.getFlatsName().equals(other.getFlatsName()))
            && (this.getCustomerIdentity() == null ? other.getCustomerIdentity() == null : this.getCustomerIdentity().equals(other.getCustomerIdentity()))
            && (this.getCustomerPhone() == null ? other.getCustomerPhone() == null : this.getCustomerPhone().equals(other.getCustomerPhone()))
            && (this.getReceiverAddress() == null ? other.getReceiverAddress() == null : this.getReceiverAddress().equals(other.getReceiverAddress()))
            && (this.getCustomerEmail() == null ? other.getCustomerEmail() == null : this.getCustomerEmail().equals(other.getCustomerEmail()))
            && (this.getCustomerLandline() == null ? other.getCustomerLandline() == null : this.getCustomerLandline().equals(other.getCustomerLandline()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.getCustomerId() == null) ? 0 : this.getCustomerId().hashCode());
        result = prime * result + ((getCustomerName() == null) ? 0 : getCustomerName().hashCode());
        result = prime * result + ((getFlatsName() == null) ? 0 : getFlatsName().hashCode());
        result = prime * result + ((getCustomerIdentity() == null) ? 0 : getCustomerIdentity().hashCode());
        result = prime * result + ((getCustomerPhone() == null) ? 0 : getCustomerPhone().hashCode());
        result = prime * result + ((getReceiverAddress() == null) ? 0 : getReceiverAddress().hashCode());
        result = prime * result + ((getCustomerEmail() == null) ? 0 : getCustomerEmail().hashCode());
        result = prime * result + ((getCustomerLandline() == null) ? 0 : getCustomerLandline().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", customerId=").append(customerId);
        sb.append(", customerName=").append(customerName);
        sb.append(", flatsName=").append(flatsName);
        sb.append(", customerIdentity=").append(customerIdentity);
        sb.append(", customerPhone=").append(customerPhone);
        sb.append(", receiverAddress=").append(receiverAddress);
        sb.append(", customerEmail=").append(customerEmail);
        sb.append(", customerLandline=").append(customerLandline);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}